Since 0.6 release SwitchYard supports basic audit mechanism. The Auditing stuff require CDI environment to run, in other words META-INF/beans.xml is necessary. It's worth to note that auditing stuff works also in test environment.
Important notes
Custom auditors should not preserve state inside any fields because dispatching order is not guaranteed and only one instance of auditor is created by default. If you would like store some values please use exchange properties or message headers. Example below shows how to count processing time using Exchange properties as temporary storage.
@Named("custom auditor")
public class SimpleAuditor implements Auditor {
private Logger _logger = Logger.getLogger(SimpleAuditor.class);
@Override
public void beforeCall(Processors processor, Exchange exchange) {
exchange.setProperty("time", System.currentTimeMillis());
}
@Override
public void afterCall(Processors processor, Exchange exchange) {
long time = System.currentTimeMillis() - exchange.getProperty("time", 0, Long.class);
_logger.info("Step " + processor.name() + " took " + time + "ms");
}
}